define(["Zepto", 
        "underscore", 
        "Backbone", 
        "Handlebars",
        "models/session",
        "text!templates/home/home.html",
        "views/common/menuview"
], function($, _, Backbone, Handlebars, Session, template, MenuView) {

    var HomePage = Backbone.View.extend({

        template: Handlebars.compile(template),

        render: function(eventName) {
            this.$el.html(this.template);
            
            // menu top
			this.menutop = new MenuView({
				el : $('#menu', this.el),
				model : this.model
			});
			this.menutop.render();
        	
            return this;
        },

        // postRender: function(eventName) {
        //     var scrollableframe = new iScroll('scrollableframe',
        //                       { useTransition:false,
        //                         checkDOMChanges: true,
        //                         hideScrollbar: true,
        //                         fixedScrollbar:true,
        //                         useTransform: false,
        //                         bounceLock: true,
        //                         onBeforeScrollStart: function (e) {
        //                             var target = e.target;
        //                             while (target.nodeType != 1) target = target.parentNode;

        //                             if (target.tagName != 'SELECT' && target.tagName != 'INPUT' && target.tagName != 'TEXTAREA' && target.tagName != 'BUTTON')
        //                                 e.preventDefault();
        //                         } }
        //                 );
        // },

        events: {
            'click #loginbutton': 'login',
            'touchstart .button': 'over',
            'touchend .button': 'left',
            'touchcancel .button': 'left',
            'touchstart button': 'over',
            'touchend button': 'left',
            'touchcancel button': 'left'
        },
         
        login: function(event) {
        	// alert('login');
        	var username = $('#username').val();
			var password = $('#password').val();
			
            Session.login({"username":username,"password":password});
        },

        over: function(event) {
            $(event.currentTarget).addClass('fake-active');
        },

        left: function(event) {
            $(event.currentTarget).removeClass('fake-active');
        }
    });

    return HomePage;

});

